package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BsEquipmentpresets;
import com.ruoyi.system.service.IBsEquipmentpresetsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 装备预设Controller
 * 
 * @author ruoyi
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/system/equipmentpresets")
public class BsEquipmentpresetsController extends BaseController
{
    @Autowired
    private IBsEquipmentpresetsService bsEquipmentpresetsService;

    /**
     * 查询装备预设列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsEquipmentpresets bsEquipmentpresets)
    {
        startPage();
        List<BsEquipmentpresets> list = bsEquipmentpresetsService.selectBsEquipmentpresetsList(bsEquipmentpresets);
        return getDataTable(list);
    }

    /**
     * 导出装备预设列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:export')")
    @Log(title = "装备预设", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsEquipmentpresets bsEquipmentpresets)
    {
        List<BsEquipmentpresets> list = bsEquipmentpresetsService.selectBsEquipmentpresetsList(bsEquipmentpresets);
        ExcelUtil<BsEquipmentpresets> util = new ExcelUtil<BsEquipmentpresets>(BsEquipmentpresets.class);
        util.exportExcel(response, list, "装备预设数据");
    }

    /**
     * 获取装备预设详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bsEquipmentpresetsService.selectBsEquipmentpresetsById(id));
    }

    /**
     * 新增装备预设
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:add')")
    @Log(title = "装备预设", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsEquipmentpresets bsEquipmentpresets)
    {
        return toAjax(bsEquipmentpresetsService.insertBsEquipmentpresets(bsEquipmentpresets));
    }

    /**
     * 修改装备预设
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:edit')")
    @Log(title = "装备预设", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsEquipmentpresets bsEquipmentpresets)
    {
        return toAjax(bsEquipmentpresetsService.updateBsEquipmentpresets(bsEquipmentpresets));
    }

    /**
     * 删除装备预设
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentpresets:remove')")
    @Log(title = "装备预设", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bsEquipmentpresetsService.deleteBsEquipmentpresetsByIds(ids));
    }
}
